/*
 * @Description  : Key Update Procedure for Present Cipher 
 * @authorName   : GuoJi
 * @github       : https://github.com/guoji-kk
 * @gitee        : https://gitee.com/guoji13663585559
 * @email        : 13663585559@163.com
 * @version      : 1.0
 * @Date         : 2023-06-02 10:46:00
 * @LastEditTime : 2023-06-02 10:46:07
 */


module key_update(data_o,data_i,round_counter);


output wire[79 : 0] data_o; // 80-bit input
input  wire[79 : 0] data_i; // 80-bit output (will be the updated value of current key)
input  wire[4  : 0] round_counter;

wire [79:0] s1,s2,s3;                       


sbox key_update_sbox(.data_o(s2[79:76]),.data_i(s1[79:76])); 

assign s1 = {data_i[18:0],data_i[79:19]};
assign s2[75:0] = s1[75:0]; 
assign s3 = {s2[79:20],(s2[19:15])^(round_counter),s2[14:0]};   
assign data_o = s3;

endmodule